package com.anyou.mall.serv.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.serv.domain.ServConfig;
import com.anyou.mall.serv.service.IServConfigService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 商品售后配置Controller
 *
 * @author ruoyi
 * @date 2023-09-23
 */
@Api(tags = "商品售后配置")
@RestController
@RequestMapping("/serv/servConfig")
public class ServConfigController extends BaseController
{
    @Autowired
    private IServConfigService servConfigService;

    /**
     * 查询商品售后配置列表
     */
    @ApiOperation("查询商品售后配置列表")
    @PreAuthorize("@ss.hasPermi('serv:servConfig:list')")
    @GetMapping("/list")
    public TableDataInfo<List<ServConfig>> list(ServConfig servConfig)
    {
        startPage();
        List<ServConfig> list = servConfigService.selectServConfigList(servConfig);
        return getDataTable(list);
    }

    /**
     * 导出商品售后配置列表
     */
    @ApiOperation("导出商品售后配置列表")
    @PreAuthorize("@ss.hasPermi('serv:servConfig:export')")
    @Log(title = "商品售后配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServConfig servConfig)
    {
        List<ServConfig> list = servConfigService.selectServConfigList(servConfig);
        ExcelUtil<ServConfig> util = new ExcelUtil<ServConfig>(ServConfig.class);
        util.exportExcel(response, list, "商品售后配置数据");
    }

//    /**
//     * 获取商品售后配置详细信息
//     */
//    @ApiOperation("获取商品售后配置详细信息")
//    @PreAuthorize("@ss.hasPermi('serv:servConfig:query')")
//    @GetMapping(value = "/{servConfigId}")
//    public ApiResult<ServConfig> getInfo(@PathVariable("servConfigId") Long servConfigId)
//    {
//        return ApiResult.success(servConfigService.selectServConfigByServConfigId(servConfigId));
//    }
    /**
     * 获取商品售后配置详细信息
     */
    @ApiOperation("售后配置详情")
    @PreAuthorize("@ss.hasPermi('serv:servConfig:servConfigInfo')")
    @GetMapping(value = "servConfigInfo")
    public ApiResult<ServConfig> servConfigInfo()
    {
        ServConfig servConfig=servConfigService.servConfigInfo();
        return ApiResult.success(servConfig);
    }

//    /**
//     * 新增商品售后配置
//     */
//    @ApiOperation("新增商品售后配置")
//    @PreAuthorize("@ss.hasPermi('serv:servConfig:add')")
//    @Log(title = "商品售后配置", businessType = BusinessType.INSERT)
//    @PostMapping
//    public ApiResult add(@RequestBody ServConfig servConfig)
//    {
//        return ApiResult.success(servConfigService.insertServConfig(servConfig));
//    }
//
//    /**
//     * 修改商品售后配置
//     */
//    @ApiOperation("修改商品售后配置")
//    @PreAuthorize("@ss.hasPermi('serv:servConfig:edit')")
//    @Log(title = "商品售后配置", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public ApiResult edit(@RequestBody ServConfig servConfig)
//    {
//        return ApiResult.success(servConfigService.updateServConfig(servConfig));
//    }

    @ApiOperation("售后配置-新增/修改")
    @PreAuthorize("@ss.hasPermi('serv:servConfig:edit')")
    @Log(title = "商品售后配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult saveOrUpdate(@RequestBody ServConfig servConfig)
    {
        servConfigService.saveOrUpdate(servConfig);
        return ApiResult.success();
    }
    /**
     * 删除商品售后配置
     */
    @ApiOperation("删除商品售后配置")
    @PreAuthorize("@ss.hasPermi('serv:servConfig:remove')")
    @Log(title = "商品售后配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{servConfigIds}")
    public ApiResult remove(@PathVariable Long[] servConfigIds)
    {
        return ApiResult.success(servConfigService.deleteServConfigByServConfigIds(servConfigIds));
    }
}
